import React, { Component } from 'react'
import { connect, Dispatch, history } from 'umi'
import { Table,Switch } from 'antd'
// import { getAddressW } from '@/service/address';

// {
//   "name": "wjx",
//   "tel": "15663597611",
//   "province": "黑龙江省",
//   "city": "哈尔滨市",
//   "county": "道外区",
//   "addressDetail": "团结",
//   "isDefault": false,
//   "userid": "user_6bef3f85-3dd1-4467-8ef1-ef91dd26e0f7",
//   "addressid": "address_8e7fab63-9d59-4c65-a6c2-b95ffe485bbc"
// },


class address extends Component {
    constructor(props:any){
        super(props)
    }
    state={
        adminList:[]
    }
    componentDidMount(){
        this.props.dispatch({
            type:'address/getAddressW'
        })
    }
    render() {
    const { addressList, dispatch } = this.props
    const columns:any = [
            {
              title: '用户名称',
              align: 'center',
              dataIndex: 'name',
              key: 'name',
                ellipsis: true,
                width: 80,
            },
            {
              title: '手机号',
              align: 'center',
              dataIndex: 'tel',
              key: 'tel',
                ellipsis: true,
                width: 80,
            },
            {
              title: '省份',
              align: 'center',
              dataIndex: 'province',
              key: 'province',
                ellipsis: true,
                width: 80,
            },
            {
                title: '市',
                align: 'center',
                dataIndex: 'city',
                key: 'city',
                ellipsis: true,
                width: 80,
            },
            {
                title: '区',
                align: 'center',
                dataIndex: 'county',
                key: 'county',
                ellipsis: true,
                width: 80,
            },
            {
                title: '详细地址',
                align: 'center',
                dataIndex: 'addressDetail',
                ellipsis: true,
                key: 'addressDetail',
                width: 80,
            },
            {
                title: '是否默认',
                align: 'center',
                ellipsis: true,
                width: 80,
                dataIndex: 'isDefault',
                render (text: string) {
                  return (
                    <Switch disabled className = "seckill_switch" checked = { text === 'true' } onChange={ () => {} } />
                  )
                }
            },
            {
                title: '用户id',
                align: 'center',
                dataIndex: 'userid',
                key: 'userid',
                ellipsis: true,
                width: 80,
            },
            {
                title: '地址id',
                align: 'center',
                dataIndex: 'addressid',
                key: 'addressid',
                ellipsis: true,
                width: 80,
            },
          ];
        return (
            <div>
                <Table dataSource={addressList} columns={columns} rowKey="addressid"/>; 
            </div>
        )
    }
}
export default connect(state=>{
    return {
      addressList: state.address.addressList
    }
})(address)